package xyz.robinbingo.effectivejava.chapter02.item02;

import cn.hutool.core.lang.Console;
import cn.hutool.json.JSONUtil;
import org.junit.Test;
import xyz.robinbingo.effectivejava.chapter02.item02.pizza.Calzone;
import xyz.robinbingo.effectivejava.chapter02.item02.pizza.NyPizza;

import static xyz.robinbingo.effectivejava.chapter02.item02.pizza.NyPizza.Size.SMALL;
import static xyz.robinbingo.effectivejava.chapter02.item02.pizza.Pizza.Topping.*;

/**
 * @author Robin
 * @date 2019/03/15 11:03
 **/
public class Item02 {

    @Test
    public void test00() {
        xyz.robinbingo.effectivejava.chapter02.item02.first.NutritionFacts cocaCola =
                new xyz.robinbingo.effectivejava.chapter02.item02.first
                        .NutritionFacts(240, 8, 100, 0, 35, 27);
        Console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        Console.log(JSONUtil.toJsonStr(cocaCola));
    }

    @Test
    public void tet01() {
        xyz.robinbingo.effectivejava.chapter02.item02.second.NutritionFacts cocaCola =
                new xyz.robinbingo.effectivejava.chapter02.item02.second.NutritionFacts();
        cocaCola.setServingSize(240);
        cocaCola.setServings(8);
        cocaCola.setCalories(100);
        cocaCola.setSodium(35);
        cocaCola.setCarbohydrate(27);
        Console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        Console.log(JSONUtil.toJsonStr(cocaCola));
    }

    @Test
    public void test02() {
        xyz.robinbingo.effectivejava.chapter02.item02.third.NutritionFacts cocaCola =
                new xyz.robinbingo.effectivejava.chapter02.item02.third.NutritionFacts
                        .Builder(240, 8).calories(100).sodium(35).carbohydrate(27).build();
        Console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        Console.log(JSONUtil.toJsonStr(cocaCola));
    }

    @Test
    public void test03() {
        NyPizza pizza = new NyPizza.Builder(SMALL).addTopping(SAUSAGE).addTopping(ONION).build();
        Calzone calzone = new Calzone.Builder().addTopping(HAM).sauceInside().build();
        Console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        Console.log(JSONUtil.toJsonStr(pizza));
        Console.log(JSONUtil.toJsonStr(calzone));
    }
}
